<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<script type="text/javascript" src="/${initParam.rootPath }/se/js/HuskyEZCreator.js" charset="UTF-8"></script>

 <b>글쓰기</b><p/>
<form action="/${initParam.rootPath }/freeboard/writeContent.do" method="post" onsubmit="return writeCheck(this);">

<table style="width:830px">
 <tr>
	<td width="100px">제목</td>
	<td><input type="text" name="title" size="50"></td>
 </tr>
 <tr>
	<td>작성자</td>
	<td><input type="text" name="name" value="${sessionScope.login_info.id }" readonly="readonly"></td>
 </tr>
 <tr>
	<td colspan=2>
		<textarea cols="110" rows="20" name="contents" id="contents"></textarea>
	</td>
 </tr>
 <tr>
 	<td colspan="2" align="center">
	 	<input type="submit" value="등록">
	 	<input type="reset" value="초기화">
	 </td>
 </tr>
 </table>
 </form>

<script type="text/javascript">
var oEditors = [];

nhn.husky.EZCreator.createInIFrame({
	oAppRef: oEditors,
	elPlaceHolder: "contents",
	sSkinURI: "/${initParam.rootPath }/se/SmartEditor2Skin.html", 
	fOnAppLoad: function(){
    	//수정모드 구현시 사용할 부분
    	var title = localStorage.getItem("title");
    	var contents = localStorage.getItem("contents");
    	document.getElementById("title").value = title;
    	oEditors.getById["contents"].exec("PASTE_HTML", [contents]);
    }, 
	fCreator: "createSEditor2"
});

	function writeCheck(form) {
		
		if (!form.title.value) {
			alert("제목을 입력하세요.");
			form.title.focus();
			return false;
		}
		
		oEditors.getById["contents"].exec("UPDATE_CONTENTS_FIELD", []);

		var ch = document.getElementById("contents").value;
		if (!ch || ch == '<p>&nbsp;</p>') {
			alert("내용을 입력하세요.");
			oEditors.getById["contents"].exec("FOCUS", []);
			return false;
		} else {
			try {
				document.form.submit();
			} catch (e) {}
		}

	};
	var pasteHTML = function(){
		var sHTML = oEditors1.getById["contents"].exec("PASTE_HTML", [sHTML]);
	};
</script>































